package weifei.mall.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.springframework.stereotype.Repository;


/**
 *
 * -- 商品 规格 表
 * -- 规格 绑定到 商品 时候，不看 商品 的 price
 * CREATE TABLE goods_specification
 * (
 *     id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
 *     group_id BIGINT UNSIGNED NOT NULL COMMENT "规格组ID",
 *     cover_id BIGINT UNSIGNED DEFAULT NULL COMMENT "商品规格封面ID",   -- 为 null 则选择一张详情图片
 *     name VARCHAR(128) NOT NULL COMMENT "商品规格名称",
 *     price FLOAT DEFAULT NULL COMMENT "规格价格",
 *     PRIMARY KEY (id),
 *     FOREIGN KEY (group_id) REFERENCES goods_specification_group(id),
 *     FOREIGN KEY (cover_id) REFERENCES goods_specification_cover(id)
 * );
 *
 * */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("goods_specification")
@Repository
public class GoodsSpecification extends Model<GoodsSpecification>
{
    @Getter
    public enum Column
    {
        ID("id"),
        GroupID("group_id"),
        CoverID("cover_id"),
        Name("name"),
        Price("price");

        final String name;
        Column(String name) { this.name = name; }
    }


    @TableId
    private Integer id;
    private Integer groupId;
    private Integer coverId;
    private String name;
    private Float price;

    public GoodsSpecification() {}
    public GoodsSpecification(int id) { this.id = id; }
}


